import request from '@/utils/request'

const baseUrl = process.env.BASE_API

export function loadDataUrl() {
  return 'workflow-service/api/workflowDefMng/loadData'
}

export function toAdd(data) {
  return request({
    url: 'workflow-service/api/workflowDefMng/toAdd',
    method: 'post',
    data
  })
}

export function flowImageUrl() {
  return baseUrl + '/workflow-service/api/workflowDefMng/viewFlowImage'
}

export function getFlowImageInfo(data) {
  return request({
    url: 'workflow-service/api/workflowDefMng/getFlowImageInfo',
    method: 'post',
    data
  })
}

export function viewMainData(data) {
  return request({
    url: 'workflow-service/api/workflowDefMng/toView',
    method: 'post',
    data
  })
}

export function addOrEdit(data) {
  return request({
    url: 'workflow-service/api/workflowDefMng/doSave',
    method: 'post',
    data
  })
}

export function getAllFlowDef() {
  return request({
    url: 'workflow-service/api/workflowDefMng/getAllFlowDef',
    method: 'get'
  })
}

export function activeFlow(data) {
  return request({
    url: 'workflow-service/api/workflowDefMng/activeFlow',
    method: 'post',
    data
  })
}

export function suspendFlow(data) {
  return request({
    url: 'workflow-service/api/workflowDefMng/suspendFlow',
    method: 'post',
    data
  })
}

export function importModel(data) {
  return request({
    url: 'workflow-service/api/workflowDefMng/importModel',
    method: 'post',
    data
  })
}

export function deployModel(data) {
  return request({
    url: 'workflow-service/api/workflowDefMng/deployModel',
    method: 'post',
    data
  })
}

export function exportModel(modelId, fileName) {
  return request({
    url: 'workflow-service/api/workflowDefMng/exportModel/' + modelId,
    method: 'get',
    fileName: fileName,
    responseType: 'blob' // 表明返回服务器返回的数据类型
  })
}

